from django.db import models

import utils
from utils.basemodel import BaseModel


# Create your models here.
class UserProfile(BaseModel):
    username = models.CharField(max_length=20, unique=True,verbose_name="用户名")
    password = models.CharField(max_length=128)
    email = models.EmailField()
    # address = models.CharField(max_length=100)
    phone = models.CharField(max_length=11)
    is_active = models.BooleanField(default=False)

    #修改表名， 应用名_类名,非驼峰
    class Meta:
        db_table = "user_userprofile"


class Address(BaseModel):
    """
    地址
    """

    addr = models.CharField(max_length=100, verbose_name='地址')
    user_profile = models.ForeignKey(UserProfile, on_delete=models.CASCADE, related_name='addresses')
    receiver = models.CharField(max_length=20, verbose_name='收件人')
    receiver_mobile=models.CharField(max_length=11, verbose_name='联系电话')
    tag=models.CharField(max_length=20, verbose_name='地址标签')
    postcode=models.CharField(max_length=6, verbose_name='邮编')
    is_default = models.BooleanField(default=False, verbose_name='是否默认')
    is_deleted = models.BooleanField(default=False, verbose_name='是否删除')

    class Meta:
        db_table = "user_address"

class Weiboprofile(BaseModel):
    """
    微博用户
    """
    user_profile = models.OneToOneField(UserProfile, on_delete=models.CASCADE, related_name='weiboprofile',null=True)
    weibo_uid = models.CharField(max_length=20, verbose_name='微博uid')
    weibo_token = models.CharField(max_length=32, verbose_name='微博令牌')

    class Meta:
        db_table = "user_weibo_profile"